#ifndef __CODE0_PARAMETER_H
#define __CODE0_PARAMETER_H

// Special type of the variables
typedef enum {WRONG = 0, CORRECT = !WRONG} PacketStatus;
typedef enum {OFF = 0, ON = !OFF} WorkStatus;
typedef enum {FALSE = 0, TRUE = !FALSE} Bool;
typedef enum {EMPTY = 0, NONEMPTY, FULL} CapacityStatus;
typedef enum {UPPER_BODY = 0, RIGHT_LEG, LEFT_LEG, BODYPART_NUM} BodyPartStatus;
typedef enum {NONE = 0, START = 1, ACT = 2, END = 3} MotionStateStatus;
typedef enum {LOW = 0, HIGH = !LOW} LevelStatus;

typedef enum {X = 0, Y = 1, Z = 2, AXIS_NUM} AxisStatus;


//
#define ID_BASE							 					0
#define TORQUE_BASE		 								50

#define MOTOR_NUM			 								27
#define MOTOR_NUM_UB									15
#define MOTOR_NUM_RL				 					6
#define MOTOR_NUM_LL				 					6

#define MOTOR_MAX_ID                  45

#define IMU_DATA_NUM                  9        //9 axis
#define FSR_NUM												10

#define MOTOR_READ_TOTAL_NUM          (MOTOR_NUM + IMU_DATA_NUM + FSR_NUM)

#define MOTOR_SCHEDULE_SIZE 					1024
#define MOTOR_SCHEDULE_LIST_LENGTH		5		
#define HEAD_SCHEDULE_SIZE 					 	64
#define HEAD_SCHEDULE_LIST_LENGTH			5
																				 
#define MOTOR_RX_BUFF_SIZE						260
//#define MASTER_RX_BUFF_SIZE						120	

// USART Packet length for Zigbee
#define ZIGBEE_RX_NUM 								6
#define ZIGBEE_TX_NUM 								6

#define WRITE_MOTOR_STEPTIME					100		// unit: ms				
#define WRITE_HEAD_STEPTIME						100		// unit: ms

#define HAED_SEARACH_SPEED_L					0 
#define HAED_SEARACH_SPEED_H					1
																																								 
int MotorNum[BODYPART_NUM] = {MOTOR_NUM_UB, MOTOR_NUM_RL, MOTOR_NUM_LL};
unsigned char MotorIDinUB[MOTOR_NUM_UB] = {0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24}; 	 
unsigned char MotorIDinRL[MOTOR_NUM_RL] = {30, 31, 32, 33, 34, 35}; 	 
unsigned char MotorIDinLL[MOTOR_NUM_LL] = {40, 41, 42, 43, 44, 45}; 

const float MX106_Resolution = 0.08789;

#define SLAVE_RX_BUFF_SIZE		128			
#define COMP_RX_BUFF_SIZE			128		 
																		 
#define P_KALMAN 							0.125
#define K_KALMAN 							0.1		
#define Q_KALMAN 							0.000001		
#define R1_KALMAN							2.0
#define R2_KALMAN							1.0

#define R_KALMAN							0.001

#define STANDFALL_BOUND_LOWER 0.3
#define STANDFALL_BOUND_UPPER 0.8

///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////

#endif /* __CODE0_PARAMETER_H */
